<?php
namespace Home\Controller;
use Think\Controller;

class ManagerController extends CommonController{
	public function index(){
		// 读取department_id
		$department_id = I('id');
    	// 关联查询
    	$UserDepartmentRelation = D('UserDepartmentRelation')->where($condition)->relation(true)->select();
		// 计算总数
		$sum_count = count($UserDepartmentRelation);
		// 数据映射
		$k = 0;
		for($j=0;$j<$sum_count;$j++){
			$department_count = count($UserDepartmentRelation[$j]['department']);
			for($i=0;$i<$department_count;$i++){
				if($UserDepartmentRelation[$j]['department'][$i]['id'] == $department_id){
					$user[$k++] = $UserDepartmentRelation[$j];
				}
			}
		}
        $this->user = $user;
		$this->display();
	}

	public function setinterview(){
		$this->display();
	}

	public function getDetail(){
		// 读取department_id
		$user_id = I('id');
    	// 关联查询
    	$UserDepartmentRelation = D('UserDepartmentRelation')->relation(true)->find($user_id);
		// 以JSON格式ajax返回
		$this->ajaxReturn($UserDepartmentRelation);
	}
}

?>